package com.screen.screendisplay.common.pojo;


public class ApiResponse<T> {
    public static final String SUCCESS_CODE = "0";
    public static final String SUCCESS_MESSAGE = "成功";
    public static final String ERROR_CODE = "-1";
    private String code = "0";
    private String message = "成功";
    private T data;

//    public static <T> ApiResponse<T> succeed() {
//        return of("0", "成功", (Object)null);
//    }
    public static <T> ApiResponse<T> succeed() {
        return of("0", "成功", (T)null);
    }

//    public static <T> ApiResponse<T> succeed(String msg) {
//        return of("0", msg, (Object)null);
//    }
    public static <T> ApiResponse<T> succeed(String msg) {
        return of("0", msg, (T)null);
    }

    public static <T> ApiResponse succeed(T data, String msg) {
        return of("0", msg, data);
    }

    public static <T> ApiResponse<T> succeed(T data) {
        return of("0", "成功", data);
    }

    public static <T> ApiResponse<T> failed(ResultCode resultCode) {
//        return of(resultCode.code(), resultCode.message(), (Object)null);
        return of(resultCode.code(), resultCode.message(), (T)null);
    }

//    public static <T> ApiResponse<T> failed(String msg) {
//        return of("-1", msg, (Object)null);
//    }
    public static <T> ApiResponse<T> failed(String msg) {
        return of("-1", msg, (T)null);
    }

    public static <T> ApiResponse<T> failed(String msg, T data) {
        return of("-1", msg, data);
    }

//    public static <T> ApiResponse<T> failed(String code, String msg) {
//        return of(code, msg, (Object)null);
//    }
    public static <T> ApiResponse<T> failed(String code, String msg) {
        return of(code, msg, (T)null);
    }

    private static <T> ApiResponse<T> of(String code, String msg, T data) {
        return new ApiResponse(code, msg, data);
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public T getData() {
        return this.data;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public void setMessage(final String message) {
        this.message = message;
    }

    public void setData(final T data) {
        this.data = data;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ApiResponse)) {
            return false;
        } else {
            ApiResponse<?> other = (ApiResponse)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label47: {
                    Object this$code = this.getCode();
                    Object other$code = other.getCode();
                    if (this$code == null) {
                        if (other$code == null) {
                            break label47;
                        }
                    } else if (this$code.equals(other$code)) {
                        break label47;
                    }

                    return false;
                }

                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof ApiResponse;
    }

    public int hashCode() {
//        int PRIME = true;
        int result = 1;
        Object $code = this.getCode();
        result = result * 59 + ($code == null ? 43 : $code.hashCode());
        Object $message = this.getMessage();
        result = result * 59 + ($message == null ? 43 : $message.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        return result;
    }

    public String toString() {
        return "ApiResponse(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }

    public ApiResponse() {
    }

    public ApiResponse(final String code, final String message, final T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}